package com.betameta.rotativobh.objects;

import com.betameta.rotativobh.R;
import com.betameta.rotativobh.enums.RotaryType;
import com.betameta.rotativobh.interfaces.IMapMarker;
import com.google.android.gms.maps.model.BitmapDescriptor;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;

public class RotaryMapMarker implements IMapMarker {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4623569353946434542L;
	
	private RotaryType rotaryType;
	private BitmapDescriptor icon;
	private LatLng position;
	private String title;
	private String description;

	@Override
	public LatLng getPosition() {
		return position;
	}

	@Override
	public void setPosition(LatLng position) {
		this.position = position;
	}

	@Override
	public String getTitle() {
		return title;
	}

	@Override
	public void setTitle(String title) {
		this.title = title;
	}

	@Override
	public String getDescription() {
		return description;
	}

	@Override
	public void setDescription(String description) {
		this.description = description;
	}

	@Override
	public BitmapDescriptor getIcon() {
		if (icon == null) {
			switch (getRotaryType()) {
				case red:
					icon = BitmapDescriptorFactory
		            		.fromResource(R.drawable.rotary_type_red);
					break;
				case blue:
					icon = BitmapDescriptorFactory
		            		.fromResource(R.drawable.rotary_type_blue);
					break;
				case green:
					icon = BitmapDescriptorFactory
		            		.fromResource(R.drawable.rotary_type_green);
					break;
				default:
					icon = BitmapDescriptorFactory
		            		.fromResource(R.drawable.rotary_type_none);
					break;
			}
		}
		return icon;
	}
	
	public RotaryType getRotaryType() {
		return this.rotaryType;
	}
	
	public void setRotaryType(RotaryType rotaryType) {
		this.rotaryType = rotaryType;
		icon = null;
	}

}
